package com.etone.smartAudit.mapstruct;

import com.etone.smartAudit.domain.ServiceExpert;
import com.etone.smartAudit.domain.Tool;
import com.etone.smartAudit.domain.ToolCase;
import com.etone.smartAudit.vo.serviceExpert.ServiceExpertDetailVO;
import com.etone.smartAudit.vo.tool.ToolDetailVO;
import com.etone.smartAudit.vo.tool.ToolVO;
import com.etone.smartAudit.vo.toolCase.ToolCaseVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.NullValueCheckStrategy;

import java.util.List;

/**
 * @author: 蒋学伟
 * @create: 2020-09-17 09:25:46
 * @Description ToolMapStruct
 */
@Mapper(componentModel = "spring", imports = {com.etone.smartAudit.vo.FileVO.class, com.alibaba.fastjson.JSONArray.class, com.alibaba.fastjson.JSON.class}, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ServiceExpertMapstruct {

    @Mappings({
            @Mapping(
                    target = "files",
                    expression = "java(serviceExpert.getFiles()==null||serviceExpert.getFiles()==\"\"?null:JSONArray.parseArray(serviceExpert.getFiles(),FileVO.class))"
            ),
            @Mapping(
                    target = "cover",
                    expression = "java(serviceExpert.getCover()==null||serviceExpert.getCover()==\"\"?null:JSON.parseObject(serviceExpert.getCover(),FileVO.class))"
            )
    })
    ServiceExpertDetailVO getServiceExpertDetailVO(ServiceExpert serviceExpert);
}
